# $FreeBSD$
#
# Provide support for Pantheon desktop related ports.
#
# Feature:	pantheon
# Usage:	USES=pantheon or USES=pantheon:ARGS
# Valid ARGS:	snapshot
#
# Variables, which can be set by the port:
#
# USE_PANTHEON		- list of components
# PANTHEON_REV		- bazaar revision
#
# MAINTAINER:	olivierd@FreeBSD.org

.if !defined(_INCLUDE_USES_PANTHEON_Mk)
_INCLUDE_USES_PANTHEON_Mk=	yes

_USE_PANTHEON_ALL=	contractor granite

_UBUNTU_TARGET?=	14.10.1

pantheon_ARGS?=	# empty

contractor_RUN_DEPENDS=	contractor:${PORTSDIR}/sysutils/contractor

granite_LIB_DEPENDS=	libgranite.so:${PORTSDIR}/x11-toolkits/granite
granite_USE_PANTHEON_REQ=	contractor

.if defined(USE_PANTHEON)
# First, expand all USE_PANTHEON_REQ recursively.
.for comp in ${_USE_PANTHEON_ALL}
.	for subcomp in ${${comp}_USE_PANTHEON_REQ}
${comp}_USE_PANTHEON_REQ+=	${${subcomp}_USE_PANTHEON_REQ}
.	endfor
.endfor

# Then, use already expanded USE_PANTHEON_REQ to expand USE_PANTHEON.
.for comp in ${USE_PANTHEON}
.	if ${_USE_PANTHEON_ALL:M${comp}} == ""
IGNORE=	cannot install: Unknown component ${comp}
.	endif
_USE_PANTHEON+=	${${comp}_USE_PANTHEON_REQ} ${comp}
.endfor

# Remove duplicate components.
USE_PANTHEON=	${_USE_PANTHEON:O:u}

.for comp in ${USE_PANTHEON}
.	if defined(${comp}_BUILD_DEPENDS)
BUILD_DEPENDS+=	${${comp}_BUILD_DEPENDS}
.	endif


.	if defined(${comp}_LIB_DEPENDS)
LIB_DEPENDS+=	${${comp}_LIB_DEPENDS}
.	endif

.       if defined(${comp}_RUN_DEPENDS)
RUN_DEPENDS+=   ${${comp}_RUN_DEPENDS}
.       endif
.endfor

.if ${pantheon_ARGS} == snapshot
DISTNAME=	${PORTNAME}_${PORTVERSION}+${PANTHEON_REV}~ubuntu${_UBUNTU_TARGET}
WRKSRC?=	${WRKDIR}/${PORTNAME}-${PORTVERSION}+${PANTHEON_REV:C/-[0-9]+//}
.endif

.endif	# end of defined(USE_PANTHEON)
.endif
